<?php
class dynamic_values_composition extends composite_table {
	/**
	 * Dynamic parameters values table
	 *
	 * @var dynamic_values
	 */
	public $dynamic_values;
	/**
	 * Dynamic parameters table
	 *
	 * @var dynamic_parameters
	 */
	public $dynamic_parameters;
	/**
	 * Dynamic fulltext values table
	 *
	 * @var dynamic_fulltext
	 */
	public $dynamic_fulltext;
	

	/**
	 * Constructor
	 *
	 * @param mixed $id
	 */
	public function __construct($id = null) {
		parent::__construct($id);
	}

	/**
	 * Gets slave table relations as array of query_criteria objects where key is relation table
	 *
	 * @return array
	 */
	protected function get_tables_relations() {
		$out = array();

		$criteria = new query_criteria();

		$criteria->add_custom_criterion(sprintf("%s.%s = %s.%s",
			$this->dynamic_values->get_table_name(), $this->dynamic_values->dparam_id->get_field_name(),
			$this->dynamic_parameters->get_table_name(), $this->dynamic_parameters->dparam_id->get_field_name()));
		$out[] = new relations_wrapper($this->dynamic_parameters->get_table_name(), join_type::$inner, $criteria);

		$criteria->reset_criteria();
		$criteria->add_custom_criterion(sprintf("%s.%s = %s.%s",
			$this->dynamic_fulltext->get_table_name(), $this->dynamic_fulltext->dvalue_id->get_field_name(),
			$this->dynamic_values->get_table_name(), $this->dynamic_values->dvalue_id->get_field_name()));
		$out[] = new relations_wrapper($this->dynamic_fulltext->get_table_name(), join_type::$inner, $criteria);
		
		return $out;
	}
}
?>